package com.nanhang.service.impl;

import cn.hutool.core.util.StrUtil;
import com.nanhang.util.PageResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nanhang.Uservo.uservo;
import com.nanhang.entity.User;
import com.nanhang.mapper.UserMapper;
import com.nanhang.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author ym
 * @since 2025-01-13
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Override
    public PageResult<User> search(Integer page, Integer pageSize, uservo vo) {

        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.like(StrUtil.isNotBlank(vo.getUsername()), "username", vo.getUsername());
        wrapper.like(StrUtil.isNotBlank(vo.getNickName()), "nick_name", vo.getNickName());

        wrapper.like(StrUtil.isNotBlank(vo.getUserLevel()), "user_level", vo.getUserLevel());

        Page<User> page1 = this.page(new Page<>(page, pageSize), wrapper);



        return new PageResult<>(page1.getRecords(),page1.getTotal());
    }
}
